package cn.itcast.nems.order.service.impl;

import cn.itcast.nems.common.constant.OrderTypeEnum;
import cn.itcast.nems.order.dao.entity.OrderEvent;
import cn.itcast.nems.order.dao.mapper.OrderEventMapper;
import cn.itcast.nems.order.service.OrderEventService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 销售订单-事件/日志 服务实现类
 * </p>
 *
 * @author liyong
 * @since 2023-08-31
 */
@Slf4j
@Service
@AllArgsConstructor
public class OrderEventServiceImpl extends ServiceImpl<OrderEventMapper, OrderEvent> implements OrderEventService {
    private final OrderEventMapper orderEventMapper;

    @Override
    public void create(String orderId, String type, String description) {
        OrderEvent orderEvent = new OrderEvent();
        orderEvent.setOrderId(orderId);
        orderEvent.setType(type);
        orderEvent.setDescription(description);
        orderEventMapper.insert(orderEvent);
    }

    @Override
    public List<OrderEvent> findListByOrderIdAndType(String orderId, OrderTypeEnum type) {
        return orderEventMapper.findListByOrderIdAndType(orderId ,type.getName());
    }
}
